﻿<?php
/**
 * The Sidebar containing the primary and secondary widget areas.
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?>

		<div id="primary" class="widget-area" role="complementary">
		
			<?php if (get_option('swt_about') == 'Display') { ?>
			<div class="cdc_about">
				<div class="cdc_about_touxiang">
					<img src="<?php echo home_url( '/' ); ?>wp-content/themes/qq-cdc/images/about_img.png" />
				</div>
				<div class="cdc_about_info">
					<p><a href="<?php echo home_url( '/' ); ?>/feed" onfocus="this.blur()" target="_blank" title="订阅我"><img src="<?php echo home_url( '/' ); ?>wp-content/themes/qq-cdc/images/rss.png" /></a>
					<a href="http://t.sina.com.cn/woallf" onfocus="this.blur()" target="_blank" title="关注我"><img src="<?php echo home_url( '/' ); ?>wp-content/themes/qq-cdc/images/sina.png" /></a>
					<a href="http://t.qq.com/woallf" onfocus="this.blur()" target="_blank" title="收听我"><img src="<?php echo home_url( '/' ); ?>wp-content/themes/qq-cdc/images/qq.png" /></a>
					<a href="mailto:woallf@foxmail.com" onfocus="this.blur()" target="_blank" title="联系我"><img src="<?php echo home_url( '/' ); ?>wp-content/themes/qq-cdc/images/email.png" /></a>
					</p>
				</div>
				<div class="clr"></div>
			</div>
			<?php }?>
			
			<?php if (get_option('swt_clock') == 'Display') { ?>
			<div class="cdc_colok">
				<embed src="http://www.clocklink.com/clocks/5012-black.swf?TimeZone=CCT&"  width="220" height="72" wmode="transparent" type="application/x-shockwave-flash">
			</div>
			<?php }?>
			
			<?php if (get_option('swt_search_g') == 'Display') { ?>
			<div class="cdc_search">
				<input name="s" type="text" value="搜索" class="cdc_s_txt" onfocus="this.value='';" onblur="if(this.value==''){this.value='搜索';}" />
				<input name="" type="submit" value="" class="cdc_so" onmouseout="this.className='cdc_so'" onmouseover="this.className='cdc_so'" />
			</div>
			<?php }?>
			
			<?php if (get_option('swt_category') == 'Display') { ?>
			<div class="cdc_cat">
				<div class="cdc_sidebar_title">
					<h1>文章分类</h1>
				</div>
				<ul><?php wp_list_categories("orderby=name&show_count=1&title_li="); ?></ul>
			</div>
			<?php }?>
			
			<div class="cdc_tblog">
				<div class="cdc_sidebar_title">
					<h1>腾讯微博</h1>
				</div>
				<iframe frameborder="0" style="border:1px solid #ccc;" scrolling="no" src="http://v.t.qq.com/show/show.php?n=woallf&w=218&h=598&fl=1&l=2&o=1&c=4&si=5359e0a2ffb5cd06e404bc0b9dbf3b20748e2cd9&cs=006400_FFFFFF_777777_EFEFEF" width="218" height="598"></iframe>
			</div>		
			
			<?php
			if ( is_active_sidebar( 'cdc1-widget-area' ) ) : ?>
				<?php dynamic_sidebar( 'cdc1-widget-area' ); ?>
			<?php endif; ?>
			
			<div class="cdc_lately">
				<div class="cdc_sidebar_title">
					<h1>最新文章</h1>
				</div>
				<ul>					
					<?php $myposts = get_posts('numberposts=10&offset=0');foreach($myposts as $post) :?>
						<li><a href="<?php the_permalink(); ?>" rel="bookmark" title="详细阅读 <?php the_title_attribute(); ?>"><?php echo cut_str($post->post_title,32); ?></a></li>
					<?php endforeach; ?>
					
				</ul>
			</div>
			
			<?php
			if ( is_active_sidebar( 'cdc2-widget-area' ) ) : ?>
				<?php dynamic_sidebar( 'cdc2-widget-area' ); ?>
			<?php endif; ?>
			
			<div class="cdc_recent_comments">
				<div class="cdc_sidebar_title">
					<h1>最新评论</h1>
				</div>
				<ul>
					<?php
						global $wpdb;
						$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url,comment_author_email, SUBSTRING(comment_content,1,14) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' AND user_id='0' ORDER BY comment_date_gmt DESC LIMIT 10";
						$comments = $wpdb->get_results($sql);
						$output = $pre_HTML;
						foreach ($comments as $comment) {$output .= "\n<li>".get_avatar(get_comment_author_email(), 32)." <p>".strip_tags($comment->comment_author).":</p><p>" . " <a href=\"" . get_permalink($comment->ID) ."#comment-" . $comment->comment_ID . "\" title=\"查看 " .$comment->post_title . "\">" . strip_tags($comment->com_excerpt)."</a></p></li>";}
						$output .= $post_HTML;
						echo $output;
					?> 
			   </ul>
			</div>
			
			<?php
			if ( is_active_sidebar( 'cdc3-widget-area' ) ) : ?>
				<?php dynamic_sidebar( 'cdc3-widget-area' ); ?>
			<?php endif; ?>
			
			<div class="cdc_tags">
				<div class="cdc_sidebar_title">
					<h1>热门标签</h1>
				</div>
				<div class="cdc_tags_show">
				<?php wp_tag_cloud('smallest=10&largest=10&number=30&orderby=count'); ?>
				</div>
			</div>			
			
			<?php
			if ( is_active_sidebar( 'cdc4-widget-area' ) ) : ?>
				<?php dynamic_sidebar( 'cdc4-widget-area' ); ?>
			<?php endif; ?>
			
			<div class="cdc_login">
				<ul>
					<?php wp_register(); ?>
					<li><?php wp_loginout(); ?></li>
					<?php wp_meta(); ?>
				</ul>
			</div>
			
			
